# 定义装饰器函数
def count_num(func):
    # 初始化装饰器变量
    count = 0

    def wrapper(*args,**kwargs):
        nonlocal count
        count += 1
        print(f"函数‘{func.__name__}’已被调用{count}次")
        return func(*args,**kwargs)   # 调用原始函数
    # 外函数返回内函数的引用
    return wrapper

# 使用装饰器来计数函数调用
@count_num
def greet(city):
    return f"Helli,{city}"

# 调用被装饰的函数
print(greet("ChangSha"))
print(greet("XiAn"))
print(greet("FuZhou"))
print(greet("NingDe"))